package com.cs171.market.entity;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonProperty;

import javax.persistence.*;
import java.time.LocalDate;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.io.Serializable;

/**
 * (Good)商品实体类
 *
 * @author yangyifei+andy+liuyijie
 * @since 2020-05-01 16:33:59
 */

@Entity
@Table(name = "good")
public class Good {
    /**
    * 商品id，自增
    */
    @Id
    @GeneratedValue //自增注解
    private Integer gid;
    /**
    * 商品名称
    */
    private String gname;
    /**
     * 轮播图url
     */
    private String carousel;
    /**
    * 商品价格
    */
    private Double gprice;
    /**
     * 原价
     */
    private Double originprice;
    /**
     * 配送费
     */
    private Double deliveryprice;
    /**
    * 商品图片
    */
    private String gimg;
    /**
    * 商品类型
    */
    private String gtype;
    /**
    * 商品上架日期
    */
    private Long gdate;
    /**
    * 商品详细描述
    */
    private String gdesc;
    /**
     * 已售
     */
    private Integer sold;
    /**
    * 商品库存
    */
    private Integer gnum;
    /**
     * 规格选择
     */
    private String choices;
    /**
     * 预计几天后送达
     */
    private Integer deliverytime;
    /**
     * 商品详细描述
     */
    private String gdescp;
    /**
     * 商品重量
     */
    private Integer weight;
    /**
     * 分类id
     */
    private Integer gcat_id;
    
    private Integer state;
    private Long addTime;
    private Long updTime;


    public Good() {
    }

    public Good(Integer gid,String gname, Double gprice, Long gdate, Integer gnum, Integer weight) {
        this.gid = gid;
        this.gname = gname;
        this.gprice = gprice;
        this.gdate = gdate;
        this.gnum = gnum;
        this.weight = weight;
    }

    public Good(Integer gid, String gname, Double gprice, Double originprice, Double deliveryprice, String gimg, String gtype, Long gdate, String gdesc, Integer gnum, String carousel, Integer sold, String choices, Integer deliverytime, String gdescp) {
        this.gid = gid;
        this.gname = gname;
        this.gprice = gprice;
        this.originprice = originprice;
        this.deliveryprice = deliveryprice;
        this.gimg = gimg;
        this.gtype = gtype;
        this.gdate = gdate;
        this.gdesc = gdesc;
        this.gnum = gnum;
        this.carousel = carousel;
        this.sold = sold;
        this.choices = choices;
        this.deliverytime = deliverytime;
        this.gdescp = gdescp;
    }
    

    public Good(Integer gid, String gname, Double gprice, String gimg, String gtype, String gdesc, Integer gnum, String choices, Integer weight, Long gdate, Integer gcat_id) {
        this.gid = gid;
        this.gname = gname;
        this.gprice = gprice;
        this.gimg = gimg;
        this.gtype = gtype;
        this.gdesc = gdesc;
        this.gnum = gnum;
        this.choices = choices;
        this.weight = weight;
        this.gdate = gdate;
        this.gcat_id = gcat_id;
    }



    public Good(Integer gid, String gname, Double gprice, String gdesc, Integer gnum, Integer weight, Long gdate, Integer gcat_id) {
        this.gid = gid;
        this.gname = gname;
        this.gprice = gprice;
        this.gdesc = gdesc;
        this.gnum = gnum;
        this.weight = weight;
        this.gdate = gdate;
        this.gcat_id = gcat_id;
    }

    public Good(Integer gid, String gname, Double gprice, Integer gnum, Integer weight, Long gdate) {
        this.gid = gid;
        this.gname = gname;
        this.gprice = gprice;
        this.gnum = gnum;
        this.weight = weight;
        this.gdate = gdate;
    }

    public Good(Integer gid, String gname, Double gprice, Integer gnum, Integer weight, Integer state, Long addTime, Long updTime) {
        this.gid = gid;
        this.gname = gname;
        this.gprice = gprice;
        this.gnum = gnum;
        this.weight = weight;
        this.state = state;
        this.addTime = addTime;
        this.updTime = updTime;
    }

    public Good(Integer gid) {
        this.gid = gid;
    }

    public Integer getGid() {
        return gid;
    }

    public void setGid(Integer gid) {
        this.gid = gid;
    }

    public String getGname() {
        return gname;
    }

    public void setGname(String gname) {
        this.gname = gname;
    }

    public Double getGprice() {
        return gprice;
    }

    public void setGprice(Double gprice) {
        this.gprice = gprice;
    }

    public String getGimg() {
        return gimg;
    }

    public void setGimg(String gimg) {
        this.gimg = gimg;
    }

    public String getGtype() {
        return gtype;
    }

    public void setGtype(String gtype) {
        this.gtype = gtype;
    }



    public String getGdesc() {
        return gdesc;
    }

    public void setGdesc(String gdesc) {
        this.gdesc = gdesc;
    }

    public Integer getGnum() {
        return gnum;
    }

    public void setGnum(Integer gnum) {
        this.gnum = gnum;
    }

    public String getCarousel() {
        return carousel;
    }

    public void setCarousel(String carousel) {
        this.carousel =carousel;
    }

    public Double getOriginprice() {
        return originprice;
    }

    public void setOriginprice(Double originprice) {
        this.originprice = originprice;
    }

    public Double getDeliveryprice() {
        return deliveryprice;
    }

    public void setDeliveryprice(Double deliveryprice) {
        this.deliveryprice = deliveryprice;
    }

    public Integer getDeliverytime() {
        return deliverytime;
    }

    public void setDeliverytime(Integer deliverytime) {
        this.deliverytime = deliverytime;
    }

    public Integer getSold() {
        return sold;
    }

    public void setSold(Integer sold) {
        this.sold = sold;
    }

    public String getGdescp() {
        return gdescp;
    }

    public void setGdescp(String gdescp) {
        this.gdescp = gdescp;
    }

    public String getChoices() {
        return choices;
    }

    public void setChoices(String choices) {
        this.choices = choices;
    }

    public Long getGdate() {
        return gdate;
    }

    public void setGdate(Long gdate) {
        this.gdate = gdate;
    }

    public Integer getWeight() {
        return weight;
    }

    public void setWeight(Integer weight) {
        this.weight = weight;
    }

    public Integer getGcat_id() {
        return gcat_id;
    }

    public void setGcat_id(Integer gcat_id) {
        this.gcat_id = gcat_id;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Long getAddTime() {
        return addTime;
    }

    public void setAddTime(Long addTime) {
        this.addTime = addTime;
    }

    public Long getUpdTime() {
        return updTime;
    }

    public void setUpdTime(Long updTime) {
        this.updTime = updTime;
    }

    public Object getMessage()
    {
        JSONObject dataJson=new JSONObject();
        dataJson.put("title",getGname());
        dataJson.put("price",getGprice());
        dataJson.put("originPrice",getOriginprice());
        dataJson.put("deliveryprice",getDeliveryprice());
        dataJson.put("sold",getSold());
        dataJson.put("stock",getGnum());
        dataJson.put("deliveryTime",getDeliverytime());
        dataJson.put("descImg",getGimg());
        return dataJson;
    }

    public Object getMessage2()
    {
        JSONObject dataJson=new JSONObject();
        dataJson.put("goods_id",getGid());
        dataJson.put("goods_name",getGname());
        dataJson.put("goods_price",getGprice());
        dataJson.put("good_number",getGnum());
        dataJson.put("goods_weight",getWeight());
        dataJson.put("goods_state",getState());
        dataJson.put("add_time",getAddTime());
        dataJson.put("upd_time",getUpdTime());
        return dataJson;
    }
}